package dto

import (
	"github.com/honwee/awm/internal/model"
	"time"
)

// GenerateAPIKeyRequest 生成API Key请求
type GenerateAPIKeyRequest struct {
	ProjectID uint64 `json:"project_id" binding:"required"`
	UserID    string `json:"user_id" binding:"required"`
}

// APIKeyResponse API Key响应
type APIKeyResponse struct {
	ProjectID uint64    `json:"project_id"`
	UserID    string    `json:"user_id"`
	Role      int8      `json:"role"`
	APIKey    string    `json:"api_key"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

// FromModel 从模型转换为响应
func (r *APIKeyResponse) FromModel(projectUser *model.ProjectUser) {
	r.ProjectID = projectUser.ProjectID
	r.UserID = projectUser.UserID
	r.Role = projectUser.Role
	r.APIKey = projectUser.APIKey
	r.CreatedAt = projectUser.CreatedAt
	r.UpdatedAt = projectUser.UpdatedAt
}
